<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		 <div class="iboxtitle">
              <span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;业务受理>接口开卡</span>
         </div>
         <input type="hidden" id="id"/>
          <div class="ibox-content ibox-zxsearchqu ">
               <div class="row">
                   <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
                  	 <div class="row">
                  	 	<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                   	    <select class="form-control" id="loanBank" name="loanBank" >
	                        	<option></option>
	                        </select>
	                     </div>
	                     <div class="col-xs-6 col-sm-6 col-md-1 col-lg-1"> 
	                     	<button class="zhixcx" type="button" onclick="query();">执行搜索</button>
	                     </div>
	                  </div>     
                   </div>
                   <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
                  	 <div class="row">
                  	 	<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                   	    <select id="nameOperatorPhone" name="nameOperatorPhone" class="form-control"></select>
	                     </div>
	                     <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"> 
	                     	<button class="zhixcx" type="button" onclick="setPaiDan();">确认派单</button>
	                     </div>
	                  </div>     
                   </div>
          		</div>
          </div>
          <div class="ibox-content">	
	          	<div class="jqGrid_wrapper">
		             <table id="table_list_1"></table>
		             <div id="pager_list_1"></div>
	         	</div>
          </div>
	</div>
    
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>

	<!-- jqGrid -->
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>	
    
    <!--
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
	    jQuery(function($) {  
	    	getData();
	    	getDataZiD();
	    	getDataS();
	    });
	    
	    var getDataZiD = function(){
		    $.dpAjax({
			    show:false,
		   		url:'${basePath}/YwShenQingZxController/getLoanBank',
		   		data:{},
				success: function(datas){
					var bankMaps = datas.bankMaps;
		 		  	if(bankMaps)
		 		  	{
		 			  var objs = '<option value="">请选择</option>';
		 			  for(var key in bankMaps)
		 			  {
		 				 objs += '<option value="'+key+'">'+bankMaps[key]+'</option>';
		 			  }
		 			  $('#loanBank').html(objs);
		 			  return;
		 		  	}
				}
			});
	    }
	    
	    var getData = function(){
	      var winWidth = $("#table_list_1").parent('div.ibox-content').width();
	      var winHeight = document.body.offsetHeight - 300;
	      var win = winWidth / 7 - 20;
  	 	  $.jgrid.defaults.styleUI = 'Bootstrap';
		  jQuery("#table_list_1").jqGrid({
			url:'${basePath}/DhOverdueListController/overdueDispatchlist',
			postData:{},
	        datatype : "json",
	        colNames : ['主键','客户id','业务id','客户姓名','性别','身份证号','分期金额','持卡人手续费','总期数','入账金额','银行', '卡余额','剩余金额'],
		    colModel : [ 
				 {name: 'replaceId',index: 'id',hidden:true},   
				 {name: 'cusId',index: 'cusId',hidden:true},   
                 {name: 'busiId',index: 'busiId',hidden:true},    
	             {name: 'cusName',index: 'cusName',width: 130,align: "center",sorttype: "float"},
	             {name: 'sexDisplay',index: 'sexDisplay',width: 130,align: "center",sorttype: "float"},
	             {name: 'cusIdno',index: 'cusIdno',width: 170,align: "center",sorttype: "float"},
	             {name: 'devideAmount',index: 'devideAmount',width: 130,align: "center",sorttype: "float"},
	             {name: 'feeTotal',index: 'feeTotal',width: 130,align: "center",sorttype: "float"},
	             {name: 'loanMonth',index: 'loanMonth',width: 130,align: "center",sorttype: "float"},
	             {name: 'amountAmortized',index: 'amountAmortized',width: 130,align: "center",sorttype: "float"},
	             {name: 'bankCodeDisplay',index: 'bankCode',width: 300,align: "center",sorttype: "float"},
	             {name: 'balanceCard',index: 'balanceCard',width: 130,align: "center",sorttype: "float"},
	             {name: 'amountRemainder',index: 'amountRemainder',width: 130,align: "center",sorttype: "float"},
	             ],
              mtype : "post",
              height: winHeight,
              width:winWidth,  
              shrinkToFit:false,
              autoScroll: false,
              rowNum: 30,
              rowList: [30, 50, 100],
              viewrecords: true,
              pager: "#pager_list_1",
              hidegrid: false,
              multiselect : true,
              altRows:true,
              altclass:'someClass',
              jsonReader : {
            	  root:"result.rows",
            	  page: "result.page",
            	  total: "result.total",
            	  records: "result.records",
            	  repeatitems: false,
            	  id: "replaceId"
              },
              loadComplete:function(datas){
            	  if (datas.flag == "100100") {
                      layer.msg("查询成功!", {icon: 6, time: 1000});
                      return;
                  }
            	  if(datas.flag == '100802') {
    				  top.location.href = thisLoginUrl;
    				  return;
    			  }

            	  layer.msg(datas.message, {icon: 2});
              }
	      });
	    }	
	    
	    window.onresize = function(){
	    	$("#table_list_1").setGridWidth($(window).width()-80);
	    }
	    
	    function getDataS() {
    		$.dpAjax({
    			show:false,
    	 		url:'${basePath}/role/getNoticeUsers',
    			data:{roleId:'afbbb20cb04f4de1b384c9f632034519'},
    			success: function(datas){
    				var sysUsers = datas.result[0].sysUsers;
    				var objs = '<option value="">请选择催收人</option>';
    				for(var i in sysUsers){
    					objs += '<option value="'+sysUsers[i].replaceId+'">'+sysUsers[i].name+'</option>';
    				}
    				$('#nameOperatorPhone').html(objs);
    			}
    	 	});
	    }
	    
	    var query = function(){
	    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
	    	var data = {};
	    	data.bankCode = $('#loanBank').val() || '';
	    	$.extend(postData, data);
	    	refresh();
	    }
	    
	    function setPaiDan(){
	    	var ids = $("#table_list_1").jqGrid("getGridParam", "selarrrow"); 
	    	var idsItem = '';
	    	var data = {};
	    	for(var i=0;i<ids.length;i++){
	    	  rowData = $("#table_list_1").jqGrid('getRowData',ids[i]);
	    	  var id = rowData.replaceId;
	    	  idsItem = id + ',';
	    	}
	    	var idsItems = idsItem.substring(0,idsItem.lastIndexOf(","));
	    	var idOperatorPhone = $("#nameOperatorPhone").val();
	    	data.id = idsItems;
	    	data.nameOperatorPhone = $("#nameOperatorPhone option:selected").text();
	    	data.idOperatorPhone = idOperatorPhone;
	    	
	    	if(idsItems == ""){
	    		layer.msg('请选择列表中订单！', {icon: 5});
				return;
	    	}
	    	if(idOperatorPhone == ""){
	    		layer.msg('请选择催收人！', {icon: 5});
				return;
	    	}
	    	$.dpAjax({
	    		url:'${basePath}/DhOverdueListController/updateDispatchBatch',
	    		data:data,
    			success: function(datas){
    				layer.msg('派单成功！', {icon: 6});
					refresh();
					return;
                 }
			});	
	    } 
	    
	    var refresh = function()
	    {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	    }
    </script>
</body>
</html>
